package com.rxyb.toolize.date.enums;

import java.util.Calendar;

/**
 * @author YJH
 * @version 1.0
 * @description 星期
 * @date 2020/6/20 16:08
 */
public enum Week {

    /**
     * 星期一
     */
    MONDAY("星期一", 1),
    /**
     * 星期二
     */
    TUESDAY("星期二", 2),
    /**
     * 星期三
     */
    WEDNESDAY("星期三", 3),
    /**
     * 星期四
     */
    THURSDAY("星期四", 4),
    /**
     * 星期五
     */
    FRIDAY("星期五", 5),
    /**
     * 星期六
     */
    SATURDAY("星期六", 6),
    /**
     * 星期日
     */
    SUNDAY("星期日", 7);

    private final String value;

    private final Integer index;

    Week(String value, Integer index) {
        this.value = value;
        this.index = index;
    }


    public String getValue() {
        return value;
    }

    public Integer getIndex() {
        return index;
    }


    /**
     * 将 {@link Calendar}星期相关值转换为Week枚举对象<br>
     *
     * @param calendarWeekIntValue Calendar中关于Week的int值
     * @return {@link Week}
     * @see #SUNDAY
     * @see #MONDAY
     * @see #TUESDAY
     * @see #WEDNESDAY
     * @see #THURSDAY
     * @see #FRIDAY
     * @see #SATURDAY
     */
    public static Week of(int calendarWeekIntValue) {
        switch (calendarWeekIntValue) {
            case 1:
                return MONDAY;
            case 2:
                return TUESDAY;
            case 3:
                return WEDNESDAY;
            case 4:
                return THURSDAY;
            case 5:
                return FRIDAY;
            case 6:
                return SATURDAY;
            case 7:
                return SUNDAY;
            default:
                return null;
        }
    }

}
